#pragma once
#include <windows.h>
#include <XInput.h>
#pragma comment(lib, "XInput.lib")

//Triggers: The value is between 0 and 255.
//Each of the thumbstick axis members is a 
//signed value between -32768 and 32767 describing 
//the position of the thumbstick. A value of 0 is centered. 
//Negative values signify down or to the left. Positive values 
//signify up or to the right. 
//XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE  7849
//XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689
//XINPUT_GAMEPAD_TRIGGER_THRESHOLD    30



class CXInput
{
	static CXInput m_Instance;
	XINPUT_STATE ControllerState;
	int ControllerNum;

	bool m_bIsADown;	
	bool m_bIsBDown;
	bool m_bIsXDown;
	bool m_bIsYDown;
	bool m_bIsStartDown;
	bool m_bIsBackDown;
	bool m_bIsRBDown;
	bool m_bIsLBDown;
	bool m_bIsRTDown;
	bool m_bIsLTDown;
	bool m_bIsUpDown;
	bool m_bIsLeftDown;
	bool m_bIsRightDown;
	bool m_bIsDownDown;
	bool m_bIsLStickMoved;
	bool m_bIsRStickMoved;

	CXInput(void);
	~CXInput(void);
	CXInput(const CXInput&);
	CXInput& operator=(const CXInput&);

public:
	static CXInput* GetInstance();

	CXInput(int playerNumber);
	XINPUT_STATE GetState();
	bool IsConnected();
	void Vibrate(int leftVal = 0, int rightVal = 0);
	DWORD PressButton();
	BYTE PullLTrigger();
	BYTE PullRTrigger();
	SHORT LStickX();
	SHORT LStickY();
	SHORT RStickX();
	SHORT RStickY();


	//Accessors
	bool GetIsADown() const { return m_bIsADown; }
	bool GetIsBDown() const { return m_bIsBDown; }
	bool GetIsXDown() const { return m_bIsXDown; }
	bool GetIsYDown() const { return m_bIsYDown; }
	bool GetIsStartDown() const { return m_bIsStartDown; }
	bool GetIsBackDown() const { return m_bIsBackDown; }
	bool GetIsRBDown() const { return m_bIsRBDown; }
	bool GetIsLBDown() const { return m_bIsLBDown; }
	bool GetIsRTDown() const { return m_bIsRTDown; }
	bool GetIsLTDown() const { return m_bIsLTDown; }
	bool GetIsUpDown() const { return m_bIsUpDown; }
	bool GetIsLeftDown() const { return m_bIsLeftDown; }
	bool GetIsRightDown() const { return m_bIsRightDown; }
	bool GetIsDownDown() const { return m_bIsDownDown; }
	bool IsLStickMoved() const { return m_bIsLStickMoved; }
	bool IsRStickMoved() const { return m_bIsRStickMoved; }

	//Mutators
	void IsLStickMoved(bool val) { m_bIsLStickMoved = val; }
	void IsRStickMoved(bool val) { m_bIsRStickMoved = val; }
	void SetIsDownDown(bool val) { m_bIsDownDown = val; }
	void SetIsRightDown(bool val) { m_bIsRightDown = val; }
	void SetIsLeftDown(bool val) { m_bIsLeftDown = val; }
	void SetIsUpDown(bool val) { m_bIsUpDown = val; }
	void SetIsLTDown(bool val) { m_bIsLTDown = val; }
	void SetIsRTDown(bool val) { m_bIsRTDown = val; }
	void SetIsLBDown(bool val) { m_bIsLBDown = val; }
	void SetIsRBDown(bool val) { m_bIsRBDown = val; }
	void SetIsBackDown(bool val) { m_bIsBackDown = val; }
	void SetIsStartDown(bool val) { m_bIsStartDown = val; }
	void SetIsYDown(bool val) { m_bIsYDown = val; }
	void SetIsXDown(bool val) { m_bIsXDown = val; }
	void SetIsBDown(bool val) { m_bIsBDown = val; }
	void SetIsADown(bool val) { m_bIsADown = val; }


};
